package com.system.server;

import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;


public class MainInter {
    GridPane gridPane=new GridPane();
    VBox finalBox=new VBox();

    public VBox creatMainUIPane(Object[] PaneList, Stage primaryStage)
    {
        Button btn1=new Button("");
        Button btn2=new Button("");
        Image image = new Image(getClass().getResourceAsStream("/images/userInter(1).png"));
        btn1.setGraphic(new ImageView(image));

        Image image1=new Image(getClass().getResourceAsStream("/images/food.png"));
        btn2.setGraphic(new ImageView(image1));

        btn1.setPrefSize(50,50);
        btn2.setPrefSize(50,50);
        btn1.setStyle("-fx-background-color: transparent;");
        btn1.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                btn1.setCursor(Cursor.HAND);
            }
        });
        btn2.setStyle("-fx-background-color: transparent;");
        btn2.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                btn2.setCursor(Cursor.HAND);
            }
        });

        btn1.setOnAction(actionEvent -> {
            finalBox.setVisible(false);
            ((VBox)PaneList[1]).setVisible(true);

            primaryStage.setWidth(500);
            primaryStage.setHeight(480);
            primaryStage.setTitle("用户管理");
        });

        btn2.setOnAction(actionEvent -> {
            finalBox.setVisible(false);
            ((VBox)PaneList[2]).setVisible(true);

            primaryStage.setWidth(500);
            primaryStage.setHeight(480);
            primaryStage.setTitle("商品管理");
        });

        //菜单栏。。。


        Label welcome=new Label("欢迎来到管理员界面");
        welcome.setFont(Font.font("欢迎来到管理员界面",FontWeight.BOLD,20));
        Label serverLabel=new Label("服务器正在运行...");

        finalBox.setAlignment(Pos.CENTER);
        gridPane.setHgap(10);
        gridPane.setVgap(10);
        gridPane.setAlignment(Pos.CENTER);
        gridPane.setPadding(new Insets(50,50,50,50));

        gridPane.add(welcome,0,0);
        gridPane.add(serverLabel,0,1);

        HBox hBox=new HBox();
        hBox.setSpacing(20);
        hBox.getChildren().add(btn1);
        hBox.getChildren().add(btn2);
        gridPane.add(hBox,0,2);

        finalBox.getChildren().addAll(gridPane);

        return finalBox;
    }

}
